function ReadingGlass(selector){
	this.ele = $(selector).get(0);
	this.ReadingGlassshowhide();
	this.smallimgshow();
}
ReadingGlass.prototype.ReadingGlassshowhide = function(){
	var oSelf = this;
	$(oSelf.ele).find('.readingglass').on({
		mouseenter:function(){
			$(oSelf.ele).find('.readingglass .glassBg').show();
			$(oSelf.ele).find('.readingglass .epitome').show();
			$(oSelf.ele).find('.readingglass .showBigReadingglass').stop().animate({
				width:'370px',
				height:'470px',
				top:0,
				left:"480px",
			})
		},
		mousemove:function(evt){
			var left = evt.offsetX-24;
			var top = evt.offsetY-24;
			if(left<=0){
				left=0
			}
			if(left>=380){
				left=380
			}
			if(top<=0){
				top=0
			}
			if(top>=382){
				top=382
			}
			$(oSelf.ele).find('.readingglass .epitome').css({
				left:left,
				top:top
			});
			$(oSelf.ele).find('.readingglass .showBigReadingglass').css({
				'background-position-x':-4*left,
				'background-position-y':-4*top
			})
			
		},
		mouseleave:function(){
			$(oSelf.ele).find('.readingglass .glassBg').hide();
			$(oSelf.ele).find('.readingglass .epitome').hide();
			$(oSelf.ele).children('.readingglass').find('.showBigReadingglass').stop().animate({
				width:0,
				height:0,
				top:'270px',
				left:'350px',
			})
		}
})
}
ReadingGlass.prototype.smallimgshow = function(){
	var oSelf = this;
	$(oSelf.ele).find('.smallshowbox .smallshow li').on({
		click:function(){
			$(oSelf.ele).children('.readingglass').css({
				'background':'url(img/miuimg/goodsimgr'+(($(this).index())+1)+'.JPG)',
				"background-size":"cover"
			});
			$(oSelf.ele).find('.readingglass .showBigReadingglass').css({
				'background':'url(img/miuimg/goodsimgr'+(($(this).index())+1)+'.JPG)',
			})
		}
	})
}

function ReadingSmallGlass(selector){
	this.ele = $(selector).get(0);
	this.btn();
	this.step = -20;
	this.smallshowleft = $(this.ele).find('.smallshow').position().left;
}
ReadingSmallGlass.prototype.btn = function() {
	var oSelf = this;
	$(oSelf.ele).find('.btnbox .btn').on({
		click: function() {
			if($(this).hasClass('left')) {
				$(oSelf.ele).find('.smallshow').animate({
						left:0
				})
				if((oSelf.smallshowleft-=oSelf.step)>= 0) {
					$(oSelf.ele).find('.smallshow').css({
						left: 0
					})
					oSelf.smallshowleft = 0;	
				}
			} else{
				if((oSelf.smallshowlefts+=oSelf.step)<= -429) {
					$(oSelf.ele).find('.smallshow').css({
						left: '-429px'
					});
					oSelf.smallshowleft = '-429px';
				}else if((oSelf.smallshowlefts)>-429){
					$(oSelf.ele).find('.smallshow').css({
						left:oSelf.smallshowleft+=oSelf.step
					})
					oSelf.smallshowleft=(oSelf.smallshowleft-oSelf.step);
				}
				$(oSelf.ele).find('.smallshow').animate({
						left:oSelf.smallshowleft+=oSelf.step
				})
			}
		}
	})
}

function Tabchange(selector){
	this.ele = $(selector).get(0);
	this.TabImg();
}
Tabchange.prototype.TabImg = function(){
	var oSelf = this;
	$(oSelf.ele).find('.btn li').on({
		click:function(){
			$(this).siblings().removeClass();
			$(this).addClass('page2style');
			$(this).index();
			$(oSelf.ele).find('.show img').attr('src','img/miuimg/'+(($(this).index())+1)+'.jpg');
		}
	})
}


function MaincontentPageChange(selector){
	this.ele = $(selector).get(0);
	this.navstyle();
	this.jumptitle();
	this.pagechange();
}
MaincontentPageChange.prototype.navstyle = function(){
	$(this.ele).find('.contentnav li').on({
		click:function(){
			$(this).siblings().removeClass('hoverstyle');
			$(this).addClass('hoverstyle');
		}
	});
}
MaincontentPageChange.prototype.jumptitle = function(){
	var oSelf = this;
	$(oSelf.ele).find('.jumpgoodstitle li').on({
		click:function(){
			$(this).siblings().find('a span').css('background-position-y','-65px');
			$(this).find('a span').css('background-position-y','-85px');
		}
	})
}
MaincontentPageChange.prototype.pagechange = function(){
	var oSelf = this;
	$(oSelf.ele).find('.contentnav li').on({
		click:function(){
			$(oSelf.ele).find('.contentpagebox').children('.page'+($(this).index()+1)).show().siblings().hide();
		}
	})
}
function KeepTop(selector){
	this.ele = $(selector).get(0);
	this.keep();
}
KeepTop.prototype.keep = function(){
	var oSelf = this;
	$(window).on({
		scroll:function(){
			if($(window).scrollTop()>=950){
			$(oSelf.ele).css({
				'position':'fixed',
				'top':0,
				'left':'132px'
			})
		}else{
			$(oSelf.ele).css({
				'position':'absolute',
				'top':0,
				'left':0
			})
		}
		}
	})
}
